namespace OracleInternal.Sharding
{
	internal class KggHashGenerator
	{
		internal static int hash(byte[] buffer)
		{
			return hash(buffer, 0, buffer.Length, 0);
		}

		internal static int hash(byte[] k, int start, int end, int thebase)
		{
			int num = end - start;
			int num2 = num;
			int num3 = start;
			int num4;
			int num5;
			int num6 = (num5 = (num4 = -1640531527));
			int num7 = thebase;
			while (num2 >= 0)
			{
				int num8 = 0;
				int num9 = 0;
				int num10 = 0;
				int num11 = 0;
				int num12 = (int)(num2 & 0xFFFFFFF0u);
				int num13 = ((num12 != 0) ? 16 : (num2 & 0xF));
				int[] array = new int[4];
				for (int num14 = num13; num14 > 0; num14--)
				{
					array[(num14 - 1) / 4] |= (k[num3 + (num14 - 1)] & 0xFF) << (num14 - 1) % 4 * 8;
				}
				num8 = array[0];
				num9 = array[1];
				num10 = array[2];
				num11 = array[3];
				num7 += ((num12 == 0) ? (num + (num11 << 8)) : num11);
				num4 += num8;
				num5 += num9;
				num6 += num10;
				num4 += num7;
				num7 += num4;
				num4 ^= (int)((uint)num4 >> 7);
				num5 += num4;
				num4 += num5;
				num5 ^= num5 << 13;
				num6 += num5;
				num5 += num6;
				num6 ^= (int)((uint)num6 >> 17);
				num7 += num6;
				num6 += num7;
				num7 ^= num7 << 9;
				num4 += num7;
				num7 += num4;
				num4 ^= (int)((uint)num4 >> 3);
				num5 += num4;
				num4 += num5;
				num5 ^= num5 << 7;
				num6 += num5;
				num5 += num6;
				num6 ^= (int)((uint)num6 >> 15);
				num7 += num6;
				num6 += num7;
				num7 ^= num7 << 11;
				num3 += 16;
				num2 -= 16;
			}
			return num7;
		}
	}
}
